
//跳转到指定商品Id详情页
function GetProDetail(id){
    Url=Url+'/ProID/'+id;
    location.href=Url;
}

//查找商品
function seachPro(){
    var pName=$('.ui-searchbar-input').find('input').val();
    if(!(pName!="" && pName.length<=20)){
        tipMsg('内容不能为空或过长!','info');
        return ;
    }
    $.post(seachProUrl,{sName:pName},function(response){
        if(response!=null){
            //console.log(response.length);
            updateProList(response);
        }
    },'json');
    
    
}

//顶部提示
function tipMsg($content,$type){
    var el;
    el=$.tips({
        content:$content,
        stayTime:2000,
        type:$type
    })
    
}

//刷新商品列表
function updateProList($data){
    //移除原来数据
    $('#proList').children("li").remove();
    
    for(var i=0;i<$data.length;i++){
         $('#proList').prepend(
            "<li class='ui-border-t ui-tag-freelimit' onclick=GetProDetail("+$data[i]['ProID']+")>"+
            "<div class='ui-list-img'>"+
            "<span><img src="+publicUrl+"/images/Products/"+$data[i]['ProImg']+" width='100px' height='68px'/></span></div>"+
            "<div class='ui-list-info'><h4 class='ui-nowrap'>"+$data[i]['ProName']+"</h4>"+
            "<p class='ui-nowrap' style='margin-top:15px;'>￥"+$data[i]['ProPrice']+"</p></div>"
        );   
    }
    
    //console.log($data[0]);
    //添加新数据
  
    
       
}

        


